cmake_minimum_required(VERSION 3.10)
set(CMAKE_VERBOSE_MAKEFILE ON)

# 设置项目名称和版本
project(onnx_demo VERSION 1.0)

# 指定 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 包含目录
include_directories(include "/usr/include/opencv4")

# 查找当前目录下的所有源文件
file(GLOB LIB_SOURCES "lib/*.cpp")

# 根据平台设置库路径
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
    # ARM64 平台
    set(ONNXRUNTIME_LIB_PATH "${CMAKE_SOURCE_DIR}/lib/arm64/libonnxruntime.so")
    set(OPENCV_LIB_PATH "/home/along/sdk/qcm6490/qirpsdk_artifacts/qirp-sdk/toolchain/install_dir/sysroots/armv8-2a-qcom-linux/usr/lib")
else()
    # x86 平台
    set(ONNXRUNTIME_LIB_PATH "${CMAKE_SOURCE_DIR}/lib/x86/libonnxruntime.so")
    set(OPENCV_LIB_PATH "/home/along/miniconda3/envs/onnx_demo/lib")
endif()

# 输出当前平台信息
message(STATUS "ONNXRUNTIME_LIB_PATH: ${ONNXRUNTIME_LIB_PATH}")
message(STATUS "OPENCV_LIB_PATH: ${OPENCV_LIB_PATH}")

# 添加可执行文件
add_executable(onnx_demo main.cpp yolov6.cpp)

# 链接库
target_link_libraries(onnx_demo
    ${ONNXRUNTIME_LIB_PATH}
    ${OPENCV_LIB_PATH}/libopencv_imgcodecs.so
    ${OPENCV_LIB_PATH}/libopencv_imgproc.so
    ${OPENCV_LIB_PATH}/libopencv_highgui.so
    ${OPENCV_LIB_PATH}/libopencv_core.so
)
